import { getStorage, setStorage } from './storage'
import store from '../store'
import dayjs from 'dayjs'

export function checkLogin () {
  if (getStorage('user_info') === null) {
    setStorage('user_info', {})
  }
  const { expire } = getStorage('user_info')
  const loginState = expire !== undefined && dayjs().unix() < expire
  store.commit('ToggleLoginState', loginState)
  return loginState
}
